// const baseUrl = 'http://jshop.mi.com';  
const baseUrl = 'http://mishop.lovemi.ren'; 

const cache = function(key, value, seconds) {
				var timestamp = Date.parse(new Date()) / 1000
				// console.log(timestamp + "===" + key)
				if (key && value === null) {
					//删除缓存
					//获取缓存
					var val = uni.getStorageSync(key);
					var tmp = uni.getStorageSync(key+'time')
					if (!tmp || timestamp >= tmp) {
						console.log("key已失效")
						uni.removeStorageSync(key)
						return false
					} else {
						console.log("获取key缓存")
						return val
					}
				} else if (key && value) {
					//设置缓存
					if (!seconds) {
						var expire = timestamp + (10)
					} else {
						var expire = timestamp + seconds
					}
					uni.setStorageSync(key, value);
					uni.setStorageSync(key+'time', expire);
				} else {
					console.log("key不能空")
				}
			};

export default {  
    baseUrl,
	cache
}